package cn.kgc.microservicecloudconsumerdept80.service;

import cn.kgc.microservicecloudapi.pojo.Category;
import cn.kgc.microservicecloudapi.pojo.ResultEntity;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ${李主席}
 * @date 2020/3/16  10:12
 */
@Component
public class CategoryClientServiceFallbackfactory implements FallbackFactory<CategoryClientService> {

    @Override
    public CategoryClientService create(Throwable throwable) {
        return new CategoryClientService() {
            @Override
            public ResultEntity<List<Category>> list() {
                return null;
            }

            @Override
            public ResultEntity<Category> get(Integer id) {
                Category category = new Category();
                category.setId(id);
                category.setName("没有数据");
                return ResultEntity.failed(category, "没有数据");
            }

            @Override
            public ResultEntity<String> update(Category category) {
                return null;
            }

            @Override
            public ResultEntity<String> insert(Category category) {
                return null;
            }

            @Override
            public ResultEntity<String> delete(Integer id) {
                return null;
            }
        };
    }
}